package com.yanqu.road.server.cmd.activity.jieshi;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.JieShiProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_CROSS_VISIT_OTHER_JIE_SHI, desc = "跨服查看他人街市信息")
public class CrossVisitOtherJieShiCmd extends CrossCommand {

    private long otherPlayerId;

    private long otherPlayerServerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        JieShiProto.CrossJieShiVisitOtherReqMsg reqMsg = JieShiProto.CrossJieShiVisitOtherReqMsg.parseFrom(packet.getBytes());
        otherPlayerId = reqMsg.getUserId();
        otherPlayerServerId = reqMsg.getServerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        JieShiProto.CrossJieShiVisitToOtherGameServerReqMsg.Builder reqMsg = JieShiProto.CrossJieShiVisitToOtherGameServerReqMsg.newBuilder();
        reqMsg.setOriginPlayerId(packet.getPlayerId());
        reqMsg.setOriginServerId(serverId);
        reqMsg.setVisitPlayerId(otherPlayerId);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_JIESHI_CROSS_VISIT_OTHER, reqMsg);
        MessageHelper.sendPacket(otherPlayerServerId, 0, message);
    }

    @Override
    public void sendData() {

    }
}
